<template>
  <div>
    <h1>查看Vue的关键帧动画效果</h1>
    <button @click="isShow = !isShow">控制显示隐藏</button>
    <transition name="two">
      <div class="text" v-show="isShow">我是动画元素</div>
    </transition>
  </div>
</template>

<script>
export default {
  name: "Anim",
  data() {
    return {
      isShow: true,
    };
  },
};
</script>

<style scoped>
.text {
  width: 200px;
  height: 50px;
  background: palevioletred;
}

@keyframes two {
  0% {
    opacity: 0;
    transform: translate(400px 0px);
  }
  50% {
    transform: translate(300px 40px);
  }
  100% {
    transform: translate(200px -40px);
  }
}
.two-enter-active{
    animation: two 1s linear;
}
.two-leave-active{
    animation: two 1s linear reverse;
}
</style>